#ifndef LINKER_H
#define LINKER_H

#include <QObject>
#include <QVector>
#include "GameData/gamedata.h"
//条件集与动作集的映射关系
enum SYMBOL
{
    BIGGER,
    LESS,
    EQUAL,
    BIGGEROREQUAL,
    LESSOREQUAL
};
enum DATAACT
{
    //加、减、乘、除、赋值
    ADD,SUB,MUL,DIV,EQU
};
struct Data{
    int i;
    QString s;
    bool b;
    float f;
    DATATYPE dataType;
};
struct Condition
{
    //数值条件
    QString name;
    QString key = "";
    SYMBOL symbol;
    Data data;
    Condition(){};
    Condition(QString& key_,SYMBOL symbol_,Data data_){
        key = key_;
        symbol = symbol_;
        data = data_;
    };
};
struct Action
{
    //数值操作
    QString key = "";
    Data data;
    DATAACT act;
    Action(QString& key_,Data& data_,DATAACT& act_)
    {
        key = key_;
        data = data_;
        act = act_;
    };
};
class Linker
{
public:
    QString name = "映射器";
    //TODO 进阶编辑：可以设定条件之间的与或非关系
    QVector<Condition*> conditions;
    QVector<Action*> actions;
    //节点跳转操作
    //只能跳一个，如果两个数据成员都非负，则默认跳branch
    int branchId = -1;
    QString branchOptionText;
    int cycleId = -1;

    //不对branch进行检查或操作
    bool AllConditionSatisfy();
    bool ConditionSatisfy(Condition* c);
    inline bool IntConditionSatisfy(Condition* c);
    inline bool StringConditionSatisfy(Condition* c);
    inline bool FloatConditionSatisfy(Condition* c);
    inline bool BoolConditionSatisfy(Condition* c);

    bool HandleAllAction();
    bool HandleAction(Action* a);
    inline bool IntAction(Action* a);
    inline bool StringAction(Action* a);
    inline bool FloatAction(Action* a);
    inline bool BoolAction(Action* a);
    Linker();
    ~Linker();
};

#endif // LINKER_H
